﻿using UnityEngine;
using System.Collections;
using Memo.Electricity.Engine;

namespace Memo.Electricity.Game
{
	public class CDoor : MemoBehaviour, ISwitchable
	{
		[SerializeField]
		private Collider2D mDeadTrigger;

		private Animator mAnimator;
		private Collider2D mCollider;

		private GameObject mUpDoor;
		private GameObject mDownDoor;

		private void Awake()
		{
			mAnimator = GetComponent<Animator>();
			mCollider = GetComponent<Collider2D>();

			mUpDoor = transform.Find("UpDoor").gameObject;
			mDownDoor = transform.Find("DownDoor").gameObject;
		}

		public void SwitchOn()
		{
			mAnimator.SetBool("IsOpen", true);
		}

		public void SwitchOff()
		{
			mAnimator.SetBool("IsOpen", false);
		}

		private void Disable()
		{
			mCollider.enabled = false;
			mDeadTrigger.enabled = false;
		}

		private void Enable()
		{
			mCollider.enabled = true;
			mDeadTrigger.enabled = true;
		}


	}
}